
<template>
    <view class="index page-view">
        <text class="font-36">广场</text>
        <view>
            <text>{{ title }}</text>
        </view>
        <button type="primary" @tap="showLoading">显示加载</button>
        <button type="primary" @tap="showToast">提交成功</button>
        <button type="primary" @tap="showToastErr">提交失败</button>
        <button type="primary" @tap="getData">获取数据</button>
        <button type="primary" @tap="goDetail">跳转到详情</button>
        <button type="primary" @tap="openModal">打开弹窗</button>
        <button type="primary" @tap="showActionSheet">ActionSheet</button>
        <button type="warn" @tap="del">删除</button>
        <button type="primary" @tap="barLoading">标题加载动画</button>
        <button type="primary" @tap="barTitle">动态标题</button>
        <button type="primary" @tap="barColor">动态颜色</button>
        <button type="primary" @tap="hideHomeButton">隐藏返回首页按钮</button>

    </view>
</template>

<script>
import './index.scss'
import {mapGetters} from "vuex"
import {toast, bus, router, format, bar} from '@/u'
import {getV2} from "@/s";
import Taro from "@tarojs/taro"

export default {
    data() {
        return {}
    },
    computed: {
        ...mapGetters(['title'])
    },
    mounted() {
        bus.$on('data', (...arg) => {
            console.log('收到消息了:', arg);
            toast.show(arg[0] + arg[1])
        })
        /*Taro.showTabBarRedDot({
            index: 0
        })*/
    },
    methods: {
        barLoading(){
            bar.loading();
            setTimeout(() => bar.hide(), 2000)
        },
        barTitle(title){
            bar.title('哈哈哈哈哈哈哈')
        },
        showLoading(){
            toast.show('加载中...', 'loading')
            setTimeout(() => {
                toast.hide();
            }, 1000)
        },
        barColor(){
            bar.color('#e64340', '#ffffff')
        },
        showToast(){
            toast.show('提交成功', 'success')
        },
        showToastErr(){
            toast.show('提交失败', 'error')
        },
        hideHomeButton(){
            bar.hideHomeButton();
        },
        getData(){
            getV2({
                stuid: 2694,
                teacherid: 1358,
                id: 216463,
                tok: '70cb3c5aef56545d482f0113df160a5b'
            }).then(res => {
                console.log('结果',res)
            })
        },
        goDetail(){
            router.push('/pages/Detail/index', {name: '11111111111'})
        },
        openModal(){
            toast.modal().then(() =>{
                toast.show('你确认了。。。')
            }).catch(() => {
                toast.show('你取消了。。。')
            })
        },
        showActionSheet(){
            toast.actionSheet().then((res) => {
                console.log('-----------',res)
            }).catch(() => {
                console.log('取消')
            })
        },
        del(){
            toast.delModal().then(() =>{
                console.log('确认删除')
            }).catch(() => {
                console.log('取消删除')
            })
        }

    }
}
</script>
